<template>
  <a-modal v-model="visible" :width="1080" title="选择用户" @ok="batchSelectItem">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="12" :lg="12" :md="12" :sm="24">
            <a-form-item label="手机号">
              <a-input placeholder="请输入手机号" v-model="queryParam.phone"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="12" :lg="12" :md="12" :sm="24">
            <a-form-item label="昵称">
              <a-input placeholder="请输入昵称" v-model="queryParam.nickname"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="12" :lg="12" :md="12" :sm="24">
            <a-form-item label="关注店铺时间">
              <a-range-picker format="YYYY-MM-DD HH:mm:ss" v-model="date1" :placeholder="['开始时间', '结束时间']" @change="onDate1Change" />
            </a-form-item>
          </a-col>
          <a-col :xl="12" :lg="12" :md="12" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>

      <a-table ref="table" size="middle" bordered rowKey="id" :columns="shopType==3?columns1:columns" :dataSource="dataSource"
        :pagination="ipagination" :loading="loading" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type:selectionType}"
        class="j-table-force-nowrap" @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="55px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a v-if="selectionType=='radio'" @click="selectItem(record)">选择</a>
        </span>

      </a-table>
    </div>

  </a-modal>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/MyJeecgListMixin'


export default {
  name: 'UmsMemberList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {},
  data () {
    return {
      pageCheckedKeys: [],
      noPageCheckedKeys: [],
      pageCheckedRows: [],
      noPageCheckedRows: [],
      visible: false,
      description: 'ums_member管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '用户头像',
          align: "center",
          dataIndex: 'headUrl',
          scopedSlots: { customRender: 'imgSlot' }
        },
        {
          title: '手机用户标识',
          align: "center",
          dataIndex: 'phone'
        },
        {
          title: '昵称',
          align: "center",
          dataIndex: 'nickname'
        },

      ],
      columns1: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '用户头像',
          align: "center",
          dataIndex: 'headUrl',
          scopedSlots: { customRender: 'imgSlot' }
        },
        {
          title: '手机用户标识',
          align: "center",
          dataIndex: 'phone'
        },
        {
          title: '昵称',
          align: "center",
          dataIndex: 'nickname'
        },
        {
          title: '关注店铺时间',
          align: "center",
          dataIndex: 'gzTime'
        }
      ],
      url: {
        list: "/tipMember/list",
        delete: "/tipMember/delete",
        deleteBatch: "/tipMember/deleteBatch",
        exportXlsUrl: "/tipMember/exportXls",
        importExcelUrl: "tipMember/importExcel",

      },
      dictOptions: {},
      date1: undefined
    }
  },
  created () {
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    searchReset () {
      this.queryParam = {
        gzShopId: this.orgCode
      }
      this.date1 = undefined
      this.loadData(1)
    },
    onDate1Change: function (value, dateString) {
      this.queryParam.gzTimeBegin = dateString[0]
      this.queryParam.gzTimeEnd = dateString[1]
    },
    open () {
      this.queryParam = {
        gzShopId: this.orgCode
      }
      this.loadData()
    },
    setSelected () {
      this.pageCheckedKeys = []
      this.noPageCheckedKeys = []
      this.pageCheckedRows = []
      this.noPageCheckedRows = []
      for (let i = 0; i < this.checkedKeys.length; i++) {
        let isSelect = false
        for (let j = 0; j < this.dataSource.length; j++) {
          if (this.dataSource[j].id == this.checkedKeys[i]) {
            isSelect = true
          }
        }
        if (isSelect) {
          this.pageCheckedKeys.push(this.checkedKeys[i])
          this.pageCheckedRows.push(this.checkedRows[i])
        } else {
          this.noPageCheckedKeys.push(this.checkedKeys[i])
          this.noPageCheckedRows.push(this.checkedRows[i])
        }
      }
      this.selectedRowKeys = this.pageCheckedKeys
    },
    initDictConfig () {
    },

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
